package com.james.controller;

import com.james.bean.SysUser;
import com.james.mapper.SysUserMapper;
import com.james.util.ResultUtil;
import com.james.util.UserUtil;
import com.james.view.ResultCode;
import com.james.view.ResultView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：zhz
 * @date ：2022/7/5 8:55
 * @description：TODO
 * @version: 1.0
 */
@RequestMapping("")
@RestController
public class SysUserController {

    @Autowired
    private SysUserMapper sysUserMapper;

    @GetMapping("/getUser")
    public ResultView getUser(){
        List<SysUser> sysUsers = sysUserMapper.selectList(null);
        return ResultUtil.getInstanceViewOfData(ResultCode.SUCCESS, sysUsers);
    }

    @PostMapping("/createUser")
    public ResultView createUser(){
        UserDetails userDetails = UserUtil.getUser();
        return ResultUtil.getInstanceViewOfData(ResultCode.SUCCESS, userDetails);
    }
}
